<!--
 * @Author: your name
 * @Date: 2019-12-13 14:00:38
 * @LastEditTime: 2019-12-13 14:36:23
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /courseware_echarts/06/index.html
 -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="../bootstrap.min.css">
    <style>
        body {
            padding-top: 80px
        }

        #search-btn {
            margin-top: 20px;
        }
    </style>
</head>

<body>

    <div class="container">
        <div class="row">
            <div class="col-md-3 col-md-offset-3">
                <form class="form-horizontal">
                    <input id="place-input" type="text" class="form-control" value="北京" placeholder="请输入地址">
                    <button type="button" id="search-btn" class="btn btn-success">
                        查询
                    </button>
                </form>

            </div>
            <div class="col-md-6">
                <div id="main" style="height:500px;"></div>
            </div>
        </div>
    </div>

    <script src="../jquery.min.js"></script>
    <script src="../echarts.min.js"></script>
    <script src="../china.js"></script>
    <script>
        $(function () {
            var key = 'tQGf0UzCs5CXwcXLBHT4U5HB0sw2EmdA'
            var url =
                `http://api.map.baidu.com/geocoding/v3/?output=json&ak=${key}&callback=?&address=`
            var ePlaceInput = $('#place-input')
            var eSearchBtn = $('#search-btn')
            eSearchBtn.click(function () {
                var place = ePlaceInput.val()
                $.getJSON(url + place)
                    .then(function (res) {
                        console.log(res)
                    })
            })
        })
    </script>
</body>

</html>